import os

from PIL import Image

#加载图片
pyimg = Image.open('python.png')
width = pyimg.width
height = pyimg.height
print(f'图像的高和宽分别是：{height}, {width}')
# print(dir(pyimg))

#截取图片
logo = pyimg.crop((70, 25, 200, 155))
logo.save('logo.png')

ms = Image.open('maishu.jpeg')
x = ms.width - logo.width
y = ms.height - logo.height
ms.paste(logo, (x, y))
ms.save('maishu2.jpeg')

#批量处理
import os
path = 'images'
out_path = 'output'
for filename in os.listdir(path):
    image = Image.open(path + '/' + filename)
    simg = image.resize((800, 800))
    x = simg.width - logo.width - 5
    y = simg.height - logo.height - 5
    simg.paste(logo, (x, y))
    simg.save(out_path + '/' + filename)